var e = require;
var t = module;
var n = l(e("YaoshuiMgr")),
o = l(e("RecorderMgr")),
i = l(e("RecorderPanel")),
a = l(e("EndMgr")),
r = l(e("SoundMgr")),
s = function(e) {
    if (e && e.__esModule) return e;
    if (null === e || "object" != typeof e && "function" != typeof e) return {
        default: e
    };
    var t = c();
    if (t && t.has(e)) return t.get(e);
    var n = {},
    o = Object.defineProperty && Object.getOwnPropertyDescriptor;
    for (var i in e) if (Object.prototype.hasOwnProperty.call(e, i)) {
        var a = o ? Object.getOwnPropertyDescriptor(e, i) : null;
        a && (a.get || a.set) ? Object.defineProperty(n, i, a) : n[i] = e[i]
    }
    n.default = e;
    t && t.set(e, n);
    return n
} (e("DataMgr"));
function c() {
    if ("function" != typeof WeakMap) return null;
    var e = new WeakMap;
    c = function() {
        return e
    };
    return e
}
function l(e) {
    return e && e.__esModule ? e: {
        default: e
    }
}
window.KillerController = {
    Instance: null
};
var d = e("LevelManager");
cc.Class({
    extends: cc.Component,
    properties: {
        ControllerType: {
            type: cc.Enum(d.AvatarControllerType),
            default: d.AvatarControllerType.BlackKiller
        },
        ControllerAnimation: dragonBones.ArmatureDisplay,
        ControllerHeadSprite: cc.Sprite,
        ControllerHandSprite: cc.Sprite,
        ControllerMHandRoot: cc.Node,
        DefaultMHandAngle: 0,
        WuqiSkins: [cc.SpriteFrame],
        HeadLevelSpriteFrames: [cc.SpriteFrame]
    },
    onLoad: function() {
        KillerController.Instance = this;
        this.freshSkin();
        s.GlobalEvent.on("SkinChange", this.freshSkin, this)
    },
    start: function() {
        LevelManager.Instance.GameCurrentOperationMode = d.GameOperationMode.Attack;
        this.DefaultMHandAngle = this.ControllerMHandRoot.angle;
        LevelManager.Instance.HealthProgressBar.progress = 0;
        this.ControllerAnimation.addEventListener(dragonBones.EventObject.START,
        function() {
            if ("attacking" == this.ControllerAnimation.animationName) {
                cc.log("attack");
                this.AFUNC_KillColourBackground()
            }
        }.bind(this), this)
    },
    SkinChange: function() {
        this.freshSkin()
    },
    freshSkin: function() {
        this.ControllerHandSprite.spriteFrame = this.WuqiSkins[s.default.Instance.curSkinNum];
        this.ControllerAnimation.armature().getSlot("武器").displayIndex = s.default.Instance.curSkinNum
    },
    onDestroy: function() {
        KillerController.Instance = null;
        s.GlobalEvent.off("SkinChange", this.freshSkin, this)
    },
    update: function(e) {
        if (!i.default.GamePause) {
            if (LevelManager.Instance.GameAllowOperation) {
                var t = LevelManager.Instance.AttackProgressBar.progress;
                t >= 0 && t < .35 ? this.ControllerHeadSprite.spriteFrame = this.HeadLevelSpriteFrames[0] : t >= .35 && t < .65 ? this.ControllerHeadSprite.spriteFrame = this.HeadLevelSpriteFrames[1] : t >= .65 && t <= 1 && (this.ControllerHeadSprite.spriteFrame = this.HeadLevelSpriteFrames[2])
            }
            LevelManager.Instance.AllowAvatarControllerMove && NPCKingController.Instance && (this.node.position.sub(NPCKingController.Instance.node.position).mag() >= LevelManager.Instance.AvatarControllerDistanceMinLimit ? this.node.x += LevelManager.Instance.AvatarControllerFastMoveSpeed * e: this.node.x += LevelManager.Instance.AvatarControllerMoveSpeed * e)
        }
    },
    AFUNC_KillColourBackground: function() {
        r.default.Instance.playSoundClip(AssetManager.Instance.AudioClips[9]);
        ColourBackground.Instance.Show();
        var e = this;
        this.scheduleOnce(function() {
            var t = cc.instantiate(AssetManager.Instance.ControllerPrefabs[1]);
            t.parent = LevelManager.Instance.SceneContentNode;
            t.position = NPCKingController.Instance.node.position;
            NPCKingController.Instance.Death(e.ControllerType);
            LevelManager.Instance.CreateRandomNPCKiller();
            n.default.Instance.ShowYaoshui();
            if (SDK.Mgr.Inst.curChannel == SDK.Define.Channel.oppo || SDK.Mgr.Inst.curChannel == SDK.Define.Channel.vivo || SDK.Mgr.Inst.curChannel == SDK.Define.Channel.tt) {
                if (a.default.Instance.hasBeingKing) Math.random() > .7 ? o.default.Instance.showSharePanel() : a.default.Instance.showSuccess();
                else {
                    a.default.Instance.hasBeingKing = !0;
                    a.default.Instance.showSuccess()
                }
                SDK.Mgr.Inst.curChannel == SDK.Define.Channel.tt && o.default.Instance.stopRecord()
            } else {
                SDK.Mgr.Inst.curChannel == SDK.Define.Channel.tt && o.default.Instance.stopRecord();
                o.default.Instance.showSharePanel()
            }
            e.node.destroy()
        },
        1)
    },
    onNonSafeKingDiscoverFunction: function() {
        LevelManager.Instance.SceneMainAudioSource.stop();
        LevelManager.Instance.GameCurrentOperationScene = d.GameSceneBlockType.Jail;
        LevelManager.Instance.AllowAvatarControllerMove = !1;
        LevelManager.Instance.GameAllowOperation = !1;
        LevelManager.Instance.CreateArmyController(this.node, this.ControllerType);
        r.default.Instance.playSoundClip(AssetManager.Instance.AudioClips[4]);
        this.scheduleOnce(function() {
            r.default.Instance.playSoundClip(AssetManager.Instance.AudioClips[5])
        },
        1);
        this.ControllerAnimation.playAnimation("jail", 1)
    },
    onSafeKingDiscoverFunction: function() {
        LevelManager.Instance.AttackProgressBar.progress = 0;
        this.ControllerAnimation.playAnimation("feign", 0);
        r.default.Instance.playSoundClip(AssetManager.Instance.AudioClips[6])
    },
    onSafeKingDiscoverFunctionOver: function() {
        this.ControllerAnimation.playAnimation("walk", 0)
    }
})